package ar.edu.unicen.exa.isistan.archassis.ia.api;

import java.util.List;

import ar.edu.unicen.exa.isistan.archassis.ia.Result;
import ar.edu.unicen.exa.isistan.archassis.ia.api.db.ListCases;
import ar.edu.unicen.exa.isistan.archassis.ia.util.BestCaseCondition;

public class ListCasesEvalResult implements ICaseSummaryData {
	private ListCases listCasesBean;
	private ItemCaseEvalResult itemCaseEvalResult;
	
	private static int count = -1; 
	
	public ListCasesEvalResult(ListCases listCasesBean) {
		this.listCasesBean = listCasesBean;
	}
	
	/**
	 * Evalua si el caso dado es mejor al caso guardado y se queda con el mejor.
	 * @param itemCaseEvalResult
	 */
	public void set(ItemCaseEvalResult itemCaseEvalResult) {
		if (this.itemCaseEvalResult == null) {
			this.itemCaseEvalResult = itemCaseEvalResult;
		} else if (BestCaseCondition.isBetter(this.itemCaseEvalResult.getHecho(), itemCaseEvalResult.getHecho(), this.itemCaseEvalResult.getSobra(), itemCaseEvalResult.getSobra())) {
			this.itemCaseEvalResult = itemCaseEvalResult;
		}
		
	}

	public ListCases getListCasesBean() {
		return listCasesBean;
	}

	@Override
	public String getName() {
		return listCasesBean.getName();
	}

	@Override
	public float getMejorHecho() {
		return this.itemCaseEvalResult.getHecho();
	}

	@Override
	public List<Result> getListResult() {
		return itemCaseEvalResult.getListResult(this);
	}

	@Override
	public int getCount() {
		count++;
		return count;
	}
	
}
